package com.LeeCode;

import java.util.Arrays;

/**
 * 划分数组使最大差为 K
 */

public class Code2294 {
    public static void main(String[] args) {
        int[] nums = {2, 2, 4, 5};
        int k = 0;
        System.out.println(new Code2294().partitionArray(nums, k));
    }

    public int partitionArray(int[] nums, int k) {
        int ans = 1, start = 0;
        Arrays.sort(nums);
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] - nums[start] <= k) continue;
            start = i;
            ans++;
        }
        return ans;
    }
}
